package com.cskaoyan.weixin.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.weixin.bean.search.SearchIndexVO;
import com.cskaoyan.weixin.service.SearchWxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx/search")
public class SearchWxController {

    @Autowired
    SearchWxService searchWxService;

    @RequestMapping("index")
    public BaseRespVo searchIndex(){
        SearchIndexVO searchIndexVO = searchWxService.querySearchIndex();
        return BaseRespVo.ok(searchIndexVO);
    }

    @RequestMapping("helper")
    public BaseRespVo searchKeyword(String keyword){
        List<String> keywords = searchWxService.searchHelper(keyword);
        return BaseRespVo.ok(keywords);
    }

    @RequestMapping("clearhistory")
    public BaseRespVo clearHistory(){
        int delete = searchWxService.clearSearchHistory();
        return BaseRespVo.ok();
    }

}
